import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "vite";

// 引入一些插件
import Vue from "@vitejs/plugin-vue";
import VueDevTools from "vite-plugin-vue-devtools"; //vue dev tool
import Autoimport from "unplugin-auto-import/vite"; //自动引入方法
import Components from "unplugin-vue-components/vite"; //自动注册组件

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    Vue(),
    // VueDevTools(),
    Autoimport({
      imports: ["vue", "vue-router", "pinia", "@vueuse/core"],
    }),
    Components({
      dirs: ["src/components/*"],
    }),
  ],
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@import "@/assets/styles/main.scss";`,
      },
    },
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    port: 5681
    ,
    host: "0.0.0.0",
    proxy: {
      '/dzz': {
        target: 'https://dzzj.yjsrpz.com/api', //目标url
        changeOrigin: true, //支持跨域
        rewrite: (path) => path.replace(/^\/dzz/, "")
      }
    }
  },
});
